﻿@model List<Entity.AssignTask>
@using TaskManager.Utils
@{
    ViewBag.Title = "List of sub Tasks";
}

@section breadcrumb
{
    <li>@Html.ActionLink("Task Manager", "Index", "Task")</li>
    <li>@Html.ActionLink("Assign Task", "Index", "AssignTask", new {id = ViewBag.Task.Id})</li>
}
<div class="row">
    <div class="col-xs-12">
        <div class="box box-primary">
            <div class="box-header">
                <h3 class="box-title">List of Sub Tasks - @ViewBag.Task.Name</h3>
            </div>
                
            <!-- /.box-header -->
            <div class="box-body table-responsive">
                @if (Helper.CurrentUser.IsManager)
                {
                    <a href="@Url.Action("Create", new {id=ViewBag.Task.Id})" class="btn btn-primary"><span class="glyphicon glyphicon-plus"></span> Add New</a>
                }
                <table id="example2" class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th>
                                Employee
                            </th>
                            <th>
                                Sub task Name
                            </th>
                            <th>
                                Start date
                            </th>
                            <th>
                                End date
                            </th>
                            <th>
                                % Completed
                            </th>
                            <th style="width: 200px">Action
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model)
                        {
                            <tr>
                                @if (item.User == null)
                                { 
                                    <td>

                                    </td>
                                }
                                else
                                {
                                    <td>
                                        @item.User.FullName
                                    </td>
                                }
                                <td>
                                    @item.Requirement
                                </td>
                                <td>
                                    @item.StartDate.ToString(Helper.FormatDate)
                                </td>
                                <td>
                                    @item.EndDate.ToString(Helper.FormatDate)
                                </td>
                                <td>
                                    @item.CompletedPercent%
                                </td>
                                <td>
                                    <a class="btn btn-default btn-flat" href="@Url.Action("Edit", new { id = item.Id })"><i class="fa fa-edit"></i></a>
                                    <a class="btn btn-default btn-flat" href="@Url.Action("Delete", new { id = item.Id })"><i class="fa fa-remove"></i></a>
                                    @if (Helper.CurrentUser.DepartmentLeader == ViewBag.Task.Leader)
                                    {
                                        <a class="btn btn-default btn-flat" href="@Url.Action("UpdateEmployee", "AssignTask", new { id = item.Id })">Assign task</a>    
                                    }
                                </td>
                                
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
            <!-- /.box-body -->
        </div>
        <!-- /.box -->
    </div>
</div>

@section Script
{
    <script type="text/javascript">
        $(function () {
            $('#example2').dataTable({
                "bPaginate": true,
                "bLengthChange": false,
                "bFilter": false,
                "bSort": false,
                "bInfo": true,
                "bAutoWidth": false,
                "aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "Tất cả"]],
                "iDisplayLength": 25,
            });
        });
</script>    
}